"""
函数定义和实现功能
def 函数名称（）：
    函数功能实现的代码

函数调用
调用方式：函数名称（）
"""

# 代码
# sum = 0
# for i in range(1,101):
#     sum += i
#     print(sum)

# 函数add_to_sum定义
def add_to_sum_a1(end_num):
    sum = 0
    for i in range(1, end_num):
        sum += i
    print(sum)

add_to_sum_a1(150)
add_to_sum_a1(180)


# 函数传参数一对一
# def add_to_sum_a2(start_num,end_num):
#     sum = 0
#     for i in range(start_num, end_num):
#         sum += i
#     print(sum)
#
# add_to_sum_a2(5,120)

# 函数传参=为默认值，可以不传（为默认值），传了就是传的参数
# def add_to_sum_a3(start_num,end_num,step=1):
#     sum = 0
#     for i in range(start_num, end_num,step):
#         sum += i
#     print(sum)
#
# add_to_sum_a3(6,130)
# add_to_sum_a3(6,130，2)

# 跳过某个默认值，直接用后面参数名字=参数
# def add_to_sum_a4(end_num,start_num=1,step=1):
#     sum = 0
#     for i in range(start_num, end_num,step):
#         sum += i
#     print(sum)
#
# add_to_sum_a4(50,step=2)

# *args表示传参不固定，随意传几个参数，输出形式为元组表示
# def add_random(name,*args):
#     print(name,args)
#
# add_random(3,1,2,3,4,5)

# def add_random1(*args):
#     print(args)
#     sum = 0
#     for num in args:
#         sum += num
#     print(f"总和为：{sum}")
#
# add_random1(1,2,3,4,5)